import request from "@/axios";
import store from "@/store";

// 内容监控
export class listenApi {
  // 内容监控列表
  static page = (params) =>
    request.getAndLoadData("/adminapi/listen/sites", params);
  // 内容监控编辑/修改分类
  static listenTypeEdit = ({ id }, params) =>
    request.postAndLoadData(`/adminapi/listen/classify/${id}`, params);
  // 内容监控导出
  static output = () => {
    const token = store.getters.user.token;
    window.open(`/api/adminapi/listen/site/output?token=${token}`);
  };
}
// 词库管理
export class keywordsApi {
  // 词库新增
  static add = (params) =>
    request.postAndLoadData(`/adminapi/keyword/add`, params);
  // 词库列表
  static page = (params) =>
    request.getAndLoadData("/adminapi/keywords", params);
  // 监控开关
  static videoSwitch = ({ id }, params) =>
    request.getAndLoadData(`/adminapi/keyword/switch/${id}`, params);
  // 删除词库
  static delete = ({ id }, params) =>
    request.delAndLoadData(`/adminapi/keyword/delete/${id}`, params);
  // 词库导入
  static import = (params) =>
    request.upload(`/adminapi/keyword/import`, params);
  // 词库导出
  static output = () => {
    const token = store.getters.user.token;
    window.open(`/api/adminapi/keyword/output?token=${token}`);
  };
}

// 图片管理
export class imagesApi {
  // 图片列表
  static page = (params) => request.getAndLoadData("/adminapi/images", params);
  // 删除图片
  static delete = ({ id }, params) =>
    request.delAndLoadData(`/adminapi/image/delete/${id}`, params);
  // 图片导入
  static import = (params) => request.upload(`/adminapi/image/import`, params);
}

// 网址库管理
export class urlsApi {
  // 网址库列表
  static page = (params) => request.getAndLoadData("/adminapi/urls", params);
  // 网址库添加
  static add = (params) => request.postAndLoadData("/adminapi/url/add", params);
  // 网址库修改
  static edit = ({ id }, params) =>
    request.postAndLoadData(`/adminapi/url/add/${id}`, params);
  // 网址库删除
  static delete = ({ id }, params) =>
    request.delAndLoadData(`/adminapi/url/delete/${id}`, params);
  // 网址库导入
  static import = (params) => request.upload(`/adminapi/url/import`, params);
  // 词库导出
  static output = () => {
    const token = store.getters.user.token;
    window.open(`/api/adminapi/url/output?token=${token}`);
  };
}

// 落地页管理
export class landingPageApi {
  // 落地页列表
  static page = (params) =>
    request.getAndLoadData("/adminapi/landing-pages", params);
  // 落地页添加
  static add = (params) =>
    request.postAndLoadData("/adminapi/landing-page/add", params);
  // 落地页删除
  static delete = ({ id }, params) =>
    request.delAndLoadData(`/adminapi/landing-page/delete/${id}`, params);
  // 落地页导入
  static import = (params) =>
    request.upload(`/adminapi/landing-page/import`, params);
  // 词库导出
  static output = () => {
    const token = store.getters.user.token;
    window.open(`/api/adminapi/landing-page/output?token=${token}`);
  };
}
